package com.lqfj.common.exception;

import com.lqfj.common.constants.ResultCodeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 自定义异常类
 */
@Data
@ApiModel(value = "全局异常")
public class KetaiException extends RuntimeException{
    @ApiModelProperty(value = "状态码")
    private Integer code;

    /**
     * 接受状态码和消息
     */
    public KetaiException(Integer code,String message){
        super(message);
        this.code=code;
    }

    /**
     * 接受枚举类型
     */
    public KetaiException(ResultCodeEnum resultCodeEnum){
        super(resultCodeEnum.getMessage());
        this.code=resultCodeEnum.getCode();
    }
    @Override
    public String toString(){
        return "KetaiException{"+
                "message="+this.getMessage()+
                ",code="+code+'}';
    }
}
